app.controller("sellerController",function ($scope,$controller,sellerService) {

    //继承baseController
    $controller("baseController",{$scope:$scope});

    $scope.entity = {};
    $scope.searchEntity = {status:'0'};
    $scope.isAgree = false ;
    $scope.list = [];
    $scope.add = function () {
        if ($scope.isAgree == true){
            sellerService.save($scope.entity).then(function (result) {
                if (result.data.success){
                    location.href="/shoplogin.html";
                }else{
                    alert(result.data.message);
                }
            })
        }else{
            alert("请先阅读相关规则");
        }
    }

    $scope.findOne = function(sellerId){
        alert(1);
        sellerService.findOne(sellerId).then(function(result){
            $scope.entity = result.data;
            console.log($scope.entity);
        })
    }

    $scope.updateStatus = function (status) {
        sellerService.updateStatus($scope.entity.sellerId,status).then(function (result) {
            if (result.data.success){
                $scope.reloadList();
            }else{
                alert(result.data.message);
            }
        })
    }


    $scope.search = function (page,rows) {
        sellerService.findPage(page,rows,$scope.searchEntity).then(function (result) {
            $scope.pageModel.totalItems = result.data.total;
            $scope.list = result.data.rows;
        })
    }

})